﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


using LRSTaxServices.Biz;
using LRSTaxServices.Common;

public partial class AdminLRS_ManageUserTaxDocuments : System.Web.UI.Page
{
    #region Types

    public enum LayoutType
    {
        Add,
        Edit,
        Search,
        View
    }

    #endregion

    #region Constants

    private const string PROP_DATASRC_UserTaxDocuments = "__UserTaxDocuments::UserTaxDocuments";
    private const string PROP_LAYOUT = "__UserTaxDocuments::UIL";
    private const string PROP_SELECTED_UserTaxDocuments_ID = "__UserTaxDocuments::SUserTaxDocumentsID";

    #endregion

    #region Public Properties

    public UserTaxDocumentsCollection DataSourceUserTaxDocuments
    {
        get { return (SessionMgr.Session[PROP_DATASRC_UserTaxDocuments] is UserTaxDocumentsCollection ? (UserTaxDocumentsCollection)SessionMgr.Session[PROP_DATASRC_UserTaxDocuments] : (UserTaxDocumentsCollection)(SessionMgr.Session[PROP_DATASRC_UserTaxDocuments] = new UserTaxDocumentsCollection())); }
        set { SessionMgr.Session[PROP_DATASRC_UserTaxDocuments] = value; }
    }

    public int SelectedUserTaxDocumentsID
    {
        get { return (SessionMgr.Session[PROP_SELECTED_UserTaxDocuments_ID] is int ? (int)SessionMgr.Session[PROP_SELECTED_UserTaxDocuments_ID] : 0); }
        set { SessionMgr.Session[PROP_SELECTED_UserTaxDocuments_ID] = value; }
    }


    public LayoutType UILayout
    {
        get { return (SessionMgr.Session[PROP_LAYOUT] is LayoutType ? (LayoutType)SessionMgr.Session[PROP_LAYOUT] : LayoutType.Search); }
        set { SessionMgr.Session[PROP_LAYOUT] = value; }
    }


    #endregion

    #region Event Handlers

    #region Page Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        if (!Page.IsPostBack)
        {
            DataSourceUserTaxDocuments = UserTaxDocuments.GetAllUserTaxDocuments();
            UserTaxDocumentsList1.DataBind(DataSourceUserTaxDocuments);
            //divexistname.Visible = false;
        }
    }

    #endregion

    #region Control: UserTaxDocumentsList

    protected void ucUserTaxDocumentsList_EditRequested(object sender, Controls_UserTaxDocumentsList.EditRequestedEventArgs evt)
    {
        //SelectedUserTaxDocumentsID = evt.TN.UserTaxDocumentsID;
        //UserTaxDocumentsViewEdit1.DataBind(evt.TN);
        //SetLayout(LayoutType.Edit);
        ////divexistname.Visible = false;
    }


    protected void ucUserTaxDocumentsList_AddNewRequested(object sender, EventArgs evt)
    {
        //UserTaxDocumentsViewEdit1.CancelEdit();
        //UserTaxDocuments newUserTaxDocuments = UserTaxDocuments.CreateNew(DataSourceUserTaxDocuments);
        //SelectedUserTaxDocumentsID = newUserTaxDocuments.UserTaxDocumentsID;
        //UserTaxDocumentsViewEdit1.DataBind(DataSourceUserTaxDocuments.FindByUserTaxDocumentsID(SelectedUserTaxDocumentsID));
        //SetLayout(LayoutType.Edit);
        ////divexistname.Visible = false;
    }


    protected void ucUserTaxDocumentsList_DataSourceRequested(object sender, EventArgs evt)
    {
        DataSourceUserTaxDocuments = UserTaxDocuments.GetAllUserTaxDocuments();
        UserTaxDocumentsList1.DataSource = DataSourceUserTaxDocuments;
    }

    #endregion

    #region Control: UserTaxDocumentsViewEdit

    //protected void ucUserTaxDocumentsViewEdit_DataSourceUserRequested(object sender, EventArgs evt)
    //{
    //    UserTaxDocumentsViewEdit1.DataSourceUserTaxDocuments = DataSourceUserTaxDocuments.FindByUserTaxDocumentsID(SelectedUserTaxDocumentsID);
    //}

    #endregion    

    #endregion

    #region Private

    #region SetLayout

    /// <summary>
    /// Configures the UI for the specified 'uiLayoutType'.
    /// </summary>
    protected void SetLayout(LayoutType uiLayoutType)
    {
        switch (uiLayoutType)
        {
            case LayoutType.Add:
            case LayoutType.Edit:

                pnlUserTaxDocumentsList.Visible = false;
                //pnlUserTaxDocumentsViewEdit.Visible = true;
                //pnlButtons.Visible = true;
                break;

            case LayoutType.View:
            case LayoutType.Search:

                pnlUserTaxDocumentsList.Visible = true;
                //pnlUserTaxDocumentsViewEdit.Visible = false;
                //pnlButtons.Visible = false;
                break;

            default:
                throw new NotImplementedException("The specified LayoutType is not supported in this release.");
        }

        //SetInitialFocus(uiLayoutType);
    }

    #endregion

    #endregion
}
